<html lang="en" xmlns:th="http://www.thymeleaf.org">
<nav class="navbar navbar-expand-lg navbar-light bg-light" th:fragment="nav-bar">

    <div class="container-fluid">
        <a class="navbar-brand" href="/index">SBlog</a>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="/index">首页</a>
                </li>
            </ul>
            <div class="d-flex" th:if="${session.user==null}">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/user/login">登入</a>
                    </li>

                    <li class="nav-item">
                        <a class="nav-link" href="/user/register">注册</a>
                    </li>
                </ul>
            </div>
            <div class="d-flex" th:if="${session.user!=null}">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/user/dashboard" th:text="${session.user.name}"></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/user/logout">登出</a>
                    </li>
                </ul>
            </div>

        </div>
    </div>
</nav>
</html>